import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import 'bootstrap/dist/css/bootstrap.css'

Vue.config.productionTip = false
Vue.prototype.$http = axios
Vue.prototype.$http.defaults.baseURL = baseUrl
router.beforeEach(async (to,from,next)=>{
  if(to.fullPath=='/')
    next()
  else{
    let token = sessionStorage.getItem('accessToken')
    let {data:ret} = await Vue.prototype.$http.get('/checkToken/'+token)
    if(ret==='ok'){
      next()
    }else{
      next({path:'/'})
    }
  }
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
